package com.smart.sms.listener;

import com.smart.sms.common.dto.SmsInfoDto;
import com.smart.sms.service.SmsService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

/**
 * @author Administrator
 */

@Component
@RocketMQMessageListener(consumerGroup = "sms-member-cg", topic = "")
public class MemberSmsListener implements RocketMQListener<SmsInfoDto> {
    @Resource
    private SmsService smsService;

    @Override
    public void onMessage(SmsInfoDto smsInfoDto) {
        if (!ObjectUtils.isEmpty(smsInfoDto)) {
            smsService.send(smsInfoDto.getPhone(), smsInfoDto.getCode());
        }
    }
}
